package com.ruoyi.cpsp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.cpsp.mapper.DepartmentMapper;
import com.ruoyi.cpsp.mapper.TeamGroupMapper;
import com.ruoyi.cpsp.domain.Department;
import com.ruoyi.cpsp.domain.TeamGroup;
import com.ruoyi.cpsp.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService
{
    @Autowired
    private DepartmentMapper departmentMapper;

    @Autowired
    private TeamGroupMapper teamGroupMapper;

    @Override
    public boolean insert(Department department)
    {
        return departmentMapper.insert(department) == 1;
    }

    @Override
    public List<Department> selectDepartmentOrder() {
        List<Department> departments = departmentMapper.selectList(new LambdaQueryWrapper<Department>()
                .orderByDesc(Department::getDepartmentStar));
        return departments;
    }

    @Override
    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }

    @Override
    public List<TeamGroup> findTeamGroupByDepart(String departmentId) {
        return teamGroupMapper.findTeamGroupByDepart(departmentId);
    }

    @Override
    public Department selectByDepartmentId(String departmentId) {
        return departmentMapper.selectByDepartmentId(departmentId);
    }
}
